# 返回不相等的第一个值得index
def find_last_of(arr, start_index):
    count = 0
    v = arr[start_index]
    for i in range(start_index + 1, len(arr)):
        if v != arr[i]:
            break

        count += 1

    return start_index + count

def compress(x):
    result = []
    start_index = 0

    while True:
        end_index = find_last_of(x, start_index)
        if end_index - start_index == 0:
            result.append(x[start_index])
        else:
            result.append([end_index - start_index + 1, x[start_index]])
        
        if end_index + 1 == len(x):
            break

        start_index = end_index + 1

    return result

str = '1122334567775443'

a = [int(c) for c in str]
b = compress(a)
print(b)